package com.lc.pianostudent.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.AsyPostForm;
import com.zcx.helper.http.note.HttpSecret;
import com.zcx.helper.http.note.HttpServer;
import com.zcx.helper.secret.SecretRSA;

import org.json.JSONObject;

/**
 * Created by Administrator on 2016/3/14.
 */
@HttpServer(Conn.SERVICE)
@HttpSecret(key = "param")
public class BaseAsyPost<T> extends AsyPostForm<T> {

    public BaseAsyPost(AsyCallBack<T> asyCallBack) {

        super(asyCallBack);

        if (Conn.ENCRYPTABLE) {
            SECRET_REQUEST = SECRET_RESPONSE = new SecretRSA("rsa_public_key.pem", "pkcs8_rsa_private_key.pem");
        }
    }

    @Override
    protected T parser(JSONObject object) throws Exception {
        TOAST = object.optString("message");
        int code = object.optInt("code");


        return code == 200? successParser(object) : null;
    }


    protected T successParser(JSONObject object) {
        return null;
    }


}
